package cn.edu.sgu.www.mhxysy.controller.potency;

import cn.edu.sgu.www.mhxysy.consts.CustomConstants;
import cn.edu.sgu.www.mhxysy.consts.CustomMessages;
import cn.edu.sgu.www.mhxysy.consts.MimeTypes;
import cn.edu.sgu.www.mhxysy.entity.potency.PotencyFruitPatternType;
import cn.edu.sgu.www.mhxysy.restful.JsonResult;
import cn.edu.sgu.www.mhxysy.service.potency.PotencyFruitPatternTypeService;
import cn.edu.sgu.www.mhxysy.vo.potency.PotencyFruitPatternTypeVO;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Api(tags = "潜能果图案类型管理")
@ApiSupport(author = CustomConstants.AUTHOR)
@Validated
@RestController
@RequestMapping(path = "/potency_fruit_pattern_type", produces = MimeTypes.APPLICATION_JSON_CHARSET_UTF_8)
public class PotencyFruitPatternTypeController {

    private final PotencyFruitPatternTypeService potencyFruitPatternTypeService;

    @Autowired
    public PotencyFruitPatternTypeController(PotencyFruitPatternTypeService potencyFruitPatternTypeService) {
        this.potencyFruitPatternTypeService = potencyFruitPatternTypeService;
    }

    @ApiOperation("查询全部潜能果图案类型")
    @RequestMapping(value = "/selectAll", method = RequestMethod.GET)
    public JsonResult<List<PotencyFruitPatternType>> selectAll() {
        List<PotencyFruitPatternType> list = potencyFruitPatternTypeService.selectAll();

        return JsonResult.success(null, list);
    }

    @ApiOperation("通过ID查询潜能果图案类型")
    @RequestMapping(value = "/selectById", method = RequestMethod.GET)
    public JsonResult<PotencyFruitPatternType> selectById(
            @ApiParam(name = "id", value = "潜能图案ID", required = true)
            @NotNull(message = CustomMessages.ID_NOT_NULL) Integer id) {
        PotencyFruitPatternType potencyFruitPatternType = potencyFruitPatternTypeService.selectById(id);

        return JsonResult.success(null, potencyFruitPatternType);
    }

    @ApiOperation("查询潜能果图案详情列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleId", value = "角色ID", required = true),
            @ApiImplicitParam(name = "schemaId", value = "潜能果方案ID", required = true)
    })
    @RequestMapping(value = "/selectDetails", method = RequestMethod.GET)
    public JsonResult<List<PotencyFruitPatternTypeVO>> selectDetails(
            @NotBlank(message = CustomMessages.ROLE_ID_NOT_NULL) String roleId,
            @NotNull(message = "潜能果方案" + CustomMessages.ID_NOT_NULL) Integer schemaId) {
        List<PotencyFruitPatternTypeVO> list = potencyFruitPatternTypeService.selectDetails(roleId, schemaId);

        return JsonResult.success(null, list);
    }

}